<?php
/**
 * Abstract.php
 *
 * Momoger_Dao 基类
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://momoger.com/license
 *
 * @category	Momoger
 * @package 	Momoger_Dao
 * @author 		Leo
 * @version    	1.0
 * @copyright  	Copyright © 2009 www.momoger.com All Rights Reserved.
 * @license    	http://momoger.com/license     New BSD License
 */

/** Zend_Db_Table_Abstract */
//require_once 'Zend/Db/Table/Abstract.php';

/**
 * Momoger_Dao 基类
 *
 * @category 	Momoger
 * @package		Momoger_Dao
 * @copyright  	Copyright © 2009 www.momoger.com All Rights Reserved.
 * @license    	http://momoger.com/license     New BSD License
 */
class Momoger_Dao_Abstract extends Zend_Db_Table_Abstract {

	/**
	 * 获取系统信息记录对象
	 *
	 * @return App_System_Logger
	 */
	public function logger() {
		return App_System_Logger::getInstance();
	}

	/**
	 * 获取系统缓存对象
	 *
	 * @return App_System_Cache
	 */
	public function cache() {
		return App_System_Cache::getInstance();
	}

	/**
	 * 获取记录总数
	 *
	 * @param string|array $where 过滤条件
	 * @return int
	 */
	public function getRowsCount($where = null) {
		$sql = $this->getAdapter()->select()->from($this->_name, 'COUNT(*) AS counts')->where($where)->__toString();
		return (int)$this->getAdapter()->fetchOne($sql);
	}
}